home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / The GIMP 2.2.8 / gimp-2.2.8-i586-setup.exe / {app} / share / gimp / 2.0 / scripts / guides-from-selection.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2005-06-30  |  1.1 KB  |  38 lines

  1. ;; -*-scheme-*- 
  2.  
  3. (define (script-fu-guides-from-selection image
  4.                      drawable) 
  5.   (let* ((boundries (gimp-selection-bounds image))
  6.      ;; non-empty INT32 TRUE if there is a selection
  7.      (selection (car boundries)) 
  8.      (x1 (cadr boundries))
  9.      (y1 (caddr boundries))
  10.      (x2 (cadr (cddr boundries))) 
  11.      (y2 (caddr (cddr boundries))))
  12.         
  13.     ;; need to check for a selection or we get guides right at edges of the image
  14.     (if (= selection TRUE) 
  15.     (begin
  16.       (gimp-image-undo-group-start image) 
  17.  
  18.       (gimp-image-add-vguide image x1)
  19.       (gimp-image-add-hguide image y1)
  20.       (gimp-image-add-vguide image x2)
  21.       (gimp-image-add-hguide image y2)
  22.  
  23.       (gimp-image-undo-group-end image)       
  24.       (gimp-displays-flush)))))
  25.  
  26. (script-fu-register "script-fu-guides-from-selection" 
  27.             _"New Guides from _Selection"
  28.             _"Creates four Guides around the bounding box of the current selection."
  29.             "Alan Horkan"
  30.             "Alan Horkan, 2004.  Public Domain."
  31.             "2004-08-13"
  32.             ""
  33.             SF-IMAGE    "Image"    0 
  34.             SF-DRAWABLE "Drawable" 0)
  35.  
  36. (script-fu-menu-register "script-fu-guides-from-selection" 
  37.              "<Image>/Image/Guides")
  38.